package com.example.administrator.mobilesafe.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.telephony.SmsManager;
import android.telephony.TelephonyManager;
import android.widget.Toast;

public class BootCompleteReceiver extends BroadcastReceiver {
    private SharedPreferences sharedPreferences ;
    private TelephonyManager telephonyManager;
    public BootCompleteReceiver() {
    }

    @Override
    public void onReceive(Context context, Intent intent) {
        sharedPreferences = context.getSharedPreferences("config", Context.MODE_PRIVATE);
        telephonyManager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
        String bindSim = sharedPreferences.getString("sim",null);
        String realSim = telephonyManager.getSimSerialNumber();
        if (bindSim.equals(realSim)){
        }else {
            String safenumber = sharedPreferences.getString("number",null);
            SmsManager smsManager = SmsManager.getDefault();
            smsManager.sendTextMessage(safenumber, null, "sim card change !", null, null);
        }
    }
}
